<template>
	<view class="movie">
		<swiper indicator-dots :circular="true" interval="3000" :autoplay="true">
			<swiper-item v-for="item in lun">
				<image :src="'http://124.93.196.45:10001'+item.advImg" style="width: 100%; height: 100%;"></image>
			</swiper-item>
		</swiper>
		<u-search v-model="value" @search="search" @custom="search"></u-search>
		<view class="m1" v-for="item in list" @click="tonext(item.id)">
			<view class="m2">
				<image :src="'http://124.93.196.45:10001'+item.cover"></image>
			</view>
			<view class="m3">
				<text>影片名称：{{item.name}}</text>
				<text>上映时间：{{item.playDate}}</text>
				<text>时长：{{item.duration}}分钟</text>
			</view>
		</view>
		<u-button type="primary" text="查看更多" style="margin-top: 10px;" v-show="key" @click="clickmore"></u-button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				lun:[],
				list:[],
				key:true,
				value:'',
				alllist:[]
			}
		},
		onLoad() {
			this.getlun()
			this.getlist()
		},
		methods: {
			getlun(){
				this.api.get('/prod-api/api/movie/rotation/list').then(res=>{
					 this.lun=res.data.rows
				})
			},
			getlist(){
				this.api.get('/prod-api/api/movie/film/list?pageNum=1&pageSize=4').then(res=>{
					this.list=res.data.rows
					this.alllist=res.data.rows
				})
			},
			clickmore(){
				this.key=false
				this.api.get('/prod-api/api/movie/film/list').then(res=>{
					this.list=res.data.rows
					this.alllist=res.data.rows
				})
			},
			search(){
				if(this.value===''){
					this.key=true
					this.list=this.alllist
					return
				}
				this.key=false
				this.api.get('/prod-api/api/movie/film/list?name='+this.value).then(res=>{
					this.list=res.data.rows
				})
			},
			tonext(id){
				uni.navigateTo({
					url:'/pages/other/movie/moviedetail/moviedetail?id='+id
				})
			}
		}
	}
</script>

<style lang="scss">
.m1{
	display: flex;
	margin-bottom: 20px;
	border-bottom: 1px solid #ccc;
	.m2{
		width: 50%;
		image{
			width: 175px;
			height: 150px;
		}
	}
	.m3{
		display: flex;
		flex-direction: column;
		line-height: 32px;
		font-size: 18px;
		
	}
}
</style>
